using System;
using System.Collections.Generic;
using System.Text;
using SpoonCore2.Client;
using SpoonCore2.Tools;
using System.Threading;

namespace SpoonCore2.Routing
{
	[Obsolete]
	class BufferTable : ITable
	{
		private readonly TimeBuffer<ClientInfo> _buffer = new TimeBuffer<ClientInfo>(100, new TimeSpan(0, 1, 0));

		public void Add(ClientInfo client)
		{
			Monitor.Enter(_buffer);
			_buffer.Add(client);
			Monitor.Exit(_buffer);
		}

		public ClientInfo FindNext(SpoonIdentifier id)
		{
			ClientInfo res = null;
			foreach (ClientInfo info in _buffer)
			{
				if (res == null) res = info;
				else if (id.NearestUp(res.Id, info.Id) == info.Id) res = info;
			}
			return res;
		}

		public IList<ClientInfo> Clients
		{
			get { return _buffer; }
		}

		public void Remove(ClientInfo client)
		{
			Monitor.Enter(_buffer);
			_buffer.Remove(client);
			Monitor.Exit(_buffer);
		}

		public bool Check(List<ClientInfo> clients)
		{
			return true;
		}

		public void Refresh()
		{
		}
	}
}